#include <header.h>
int main(int argc, char* argv[]){
	ARGS_CHECK(argc, 1);

	char *port = "8080";
	char *ip = "192.168.169.128";
	int socket_fd = socket(AF_INET, SOCK_STREAM, 0);

	struct sockaddr_in clientaddr;
	clientaddr.sin_family = AF_INET;
	clientaddr.sin_port = htons(atoi(port));
	clientaddr.sin_addr.s_addr = inet_addr(ip);

	int ret = connect(socket_fd, (struct sockaddr*)&clientaddr, sizeof clientaddr);
	ERROR_CHECK(ret, -1, "connect");


	while(1){
		// TODO read stdin
		char buf[1 << 10] = {0};
		read(STDIN_FILENO, buf, sizeof buf);

		send(socket_fd, buf, sizeof buf, 0);

		// read from socket
		__bzero(buf, sizeof buf);
		recv(socket_fd, buf, sizeof buf, 0);
		printf("server:%s\n", buf);

	}



	close(socket_fd);
	return 0;
}